import { findByMobile } from "../../../api/member";

Component({
    /**
     * 组件的属性列表
     */
    properties: {
        title: {
            type: String,
            value: '代客下单',
        },
        inputType: {
            type: String,
            value: 'text',
        }
    },

    /**
     * 组件的初始数据
     */
    data: {
        dialogType: false,
        inputData: '',
        saveClickFlag: true,
        time: null,
    },
    /**
     * 组件的方法列表
     */
    methods: {
        cloneClick() {
            this.data.dialogType = false
            this.setData({
                dialogType: this.data.dialogType
            })
        },
        appear() {
            this.data.dialogType = true
            this.data.inputData = ''
            this.setData({
                dialogType: this.data.dialogType
            })
        },
        inputClick(e) {
            const that = this
            clearTimeout(this.data.time);
            this.data.time = setTimeout(() => {
                console.log(e)
                that.data.inputData = e.detail.value
                that.setData({
                    inputData: that.data.inputData
                })
            }, 700)
        },
        saveClick() {
            if (this.data.saveClickFlag == true) {
                this.data.saveClickFlag = false
                this.setData({
                    saveClickFlag: this.data.saveClickFlag
                })
                let settime = setTimeout(() => {
                    this.data.saveClickFlag = true
                    this.setData({
                        saveClickFlag: this.data.saveClickFlag
                    })
                    clearTimeout(settime)
                }, 2000)
                if (this.data.inputData == '') {
                    wx.showToast({
                        icon: "none",
                        title: '请输入手机号码',
                    })
                    return
                }
                let params = {
                    mobile: this.data.inputData
                }
                findByMobile(params).then(res => {
                    this.triggerEvent('getMember', res.data)
                    this.data.dialogType = false
                    this.setData({
                        dialogType: this.data.dialogType
                    })
                })
            }
        }



    }
})
